//
//  BGSafeCenterViewController.m
//  bigMall
//
//  Created by ios on 16/7/19.
//  Copyright © 2016年 thinklev. All rights reserved.
//

#import "BGSafeCenterViewController.h"
#import "BGSafeCenterTableViewCell.h"
#import "BGXGpwdController.h"
#import "BGXGphoneController.h"
#import "BGXGpayController.h"
#import "BGFindpayController.h"

@interface BGSafeCenterViewController () <UITableViewDelegate,UITableViewDataSource> {
    
    UITableView *_tableView;
    NSArray *_title;
    
}

@end

@implementation BGSafeCenterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = GWColor(244, 244, 244, 1);
    
    [self createUI];
    
    UIBarButtonItem *backIetm = [[UIBarButtonItem alloc] init];
    backIetm.title =@"";
    self.navigationItem.backBarButtonItem = backIetm;
    
}
- (void)createUI {
    
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    
    _tableView.delegate = self;
    
    _tableView.dataSource = self;
    
//    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.view addSubview:_tableView];
    
}
#pragma mark - datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
        
        return 3;
        
    }else {
        
        return 1;
        
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 68;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    if (section == 0) {
        
        return 10;
        
    }else {
        
        return 1;
        
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    
    return 0;
    
}

#pragma mark - delegate
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView registerNib:[UINib nibWithNibName:@"BGSafeCenterTableViewCell" bundle:nil] forCellReuseIdentifier:@"celId"];
    
    BGSafeCenterTableViewCell *cel = [tableView dequeueReusableCellWithIdentifier:@"celId" forIndexPath:indexPath];
    
    cel.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            
            cel.title.text = @"登录密码";
            cel.text.text = @"已设置";
            
        }else if (indexPath.row == 1) {
            
            cel.title.text = @"手机号";
            cel.text.text = @"已设置";
            
        }else {
            
            cel.title.text = @"支付密码";
            cel.text.text = @"已设置";
            
        }
        
    }else {
        
        cel.title.text = @"支付密码找回";
        cel.text.text = @"已设置";
        
    }
    
    return cel;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            
            BGXGpwdController *a = [[BGXGpwdController alloc] init];
            
            [self.navigationController pushViewController:a animated:YES];
            
        }else if (indexPath.row == 1) {
            
            BGXGphoneController *a = [[BGXGphoneController alloc] init];
            
            [self.navigationController pushViewController:a animated:YES];
            
        }else {
            
            BGXGpayController *a = [[BGXGpayController alloc] init];
            
            [self.navigationController pushViewController:a animated:YES];
            
        }
        
    } else {
        
        BGFindpayController * a = [[BGFindpayController alloc] init];
        
        [self.navigationController pushViewController:a animated:YES];
        
    }
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
